package com.hh.test.util;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class ScannerUtil {

	public static Integer[] getIntArrayInput() {
		List<Integer> list = new ArrayList<Integer>();
		try (InputStreamReader input = new InputStreamReader(System.in);
				BufferedReader read = new BufferedReader(input);) {

			while (true) {
				try {
					String str = read.readLine();
					if (str.equals("")) {
						break;
					}
					if (str.matches("\\d*")) {
						list.add(Integer.valueOf(str));
					} else {
						System.out.println("请输入数字");
					}

				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list.toArray(new Integer[list.size()]);
	}
}
